/**
 * Created by Administrator on 2017/6/12 0012.
 * by郑春阳
 */
/**
 自开发 -> json to form js工具
 生成form最终表单
 name:表单name
 action:表单提交地址
 method:提交方式 get / post
 json:需要生成的表单dom集合
 */

/**
 * 可拓展json结构
 */
var dic_list = '';
var pro_list = '';
function formStart_sub(data){
    var item_name = data.name; //子集名称
    var change_item = data.change_item;//已经提交审核的子集项
    dic_list = data.dic;
    pro_list = data.pro_dic;
    var form = createForm({action:data.action,name:data.name,method:data.method});
    //追加表格数据
    form.append($('<div class="weui-cells_form"></div>'));
    //检测该子集是否有值
    var default_value = data.value;
    //获取子集结构
    var json = data.json;
    //获取扩展配置信息
    var kz_json = data.kz_json;
    //获取对象长度
    var a = 0;
    for(var i in json){
        a++;
    }
    if(a==0){
        //这里使用weui样式
        alert('没有该子集显示项!');
        history.back(-1);
        return;
    }
    if( (default_value==undefined) || (default_value.length==0) ){
        //无值状态 加载默认数据
        for(var i in json){
            //检测是否是为时间标签
            if(json[i].type=='DATE'){
                var date_html = '<div class=" form-group "><label class="col-sm-2  control-label" for="inputDate"></label><div class="col-sm-4"><div class=""></div></div></div>';
                //生成date节点
                var date_obj = $(date_html);
                //生成左侧标题 必填加上*
                if(kz_json[i].file){
                    var html = json[i].caption+'<font color="red">*</font>';
                }else{
                    var html = json[i].caption;
                }
                date_obj.find('label').eq(0).html(html);
                //生成右侧日期input表单
                var createDateValue = {
                    name:i,
                    value:json[i].value,
                    caption:json[i].caption
                };

                var temp_date = createTime(createDateValue,kz_json[i]);
                date_obj.find('div:eq(1)').append(temp_date);
                form.find('div:eq(0)').append(date_obj);

            }else if(json[i].type=='LIST'){
                //生成select节点
                //<div class="form-group"><div class="col-sm-10"><select class="form-control" id=""><option value=""></option></select></div></div>
                var select_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputList"></label><div class="col-sm-4"><div class=""></div></div></div>';
                var select_obj = $(select_html);
                //生成左侧标题 必填加上*
                if(kz_json[i].file){
                    var html = json[i].caption+'<font color="red">*</font>';
                }else{
                    var html = json[i].caption;
                }
                select_obj.find('label').eq(0).html(html);
                //分析字典 默认值
                var dictionaries = json[i].dictionaries;
                var select_data = {
                    name:i,
                    dictionaries:dictionaries
                };
                var select = createSelect(select_data,kz_json[i]);
                select_obj.find('div:eq(1)').append(select);
                form.find('div:eq(0)').append(select_obj);
            }else if(json[i].type=='NUMBER'){
                var number_html = '<div class=" form-group "><label class="col-sm-2  control-label" for="inputNumber"></label><div class="col-sm-4"><div class=""></div></div></div>';
                //生成text节点
                var number_obj = $(number_html);
                //生成左侧标题 必填加上*
                if(kz_json[i].file){
                    var html = json[i].caption+'<font color="red">*</font>';
                }else{
                    var html = json[i].caption;
                }
                number_obj.find('label').eq(0).html(html);
                //生成右侧文本input表单
                var createNumberValue = {
                    name:i,
                    value:json[i].value,
                    caption:json[i].caption,
                    change_type:json[i].change_type
                };
                var temp_number = createNumber(createNumberValue,kz_json[i]);
                number_obj.find('div:eq(1)').append(temp_number);
                form.find('div:eq(0)').append(number_obj);
            }else if(json[i].type=='LIST-1'){
                var checked_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputChecked"></label><div class="col-sm-4 check_radio"><div class=""></div></div></div>';
                //生成单选节点
                var checked_obj = $(checked_html);
                //生成左侧标题 必填加上*
                if(kz_json[i].file){
                    var html = json[i].caption+'<font color="red">*</font>';
                }else{
                    var html = json[i].caption;
                }
                checked_obj.find('label').eq(0).html(html);
                //生成右侧文本input表单
                var createCheckedValue = {
                    name:i,
                    value:json[i].value,
                    caption:json[i].caption
                };
                var temp_checked = createChecked(createCheckedValue,kz_json[i]);
                checked_obj.find('div:eq(1)').append(temp_checked);
                form.find('div:eq(0)').append(checked_obj);
            }else{
                var text_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputText"></label><div class="col-sm-4"><div class=""></div></div></div>';
                //生成text节点
                var text_obj = $(text_html);
                //生成左侧标题 必填加上*
                if(kz_json[i].file){
                    var html = json[i].caption+'<font color="red">*</font>';
                }else{
                    var html = json[i].caption;
                }
                text_obj.find('label').eq(0).html(html);
                //生成右侧文本input表单
                var createTextValue = {
                    name:i,
                    value:json[i].value,
                    caption:json[i].caption
                };
                var temp_text = createText(createTextValue,kz_json[i]);
                text_obj.find('div:eq(1)').append(temp_text);
                form.find('div:eq(0)').append(text_obj);
            }
        }

        //生成提交按钮 和 返回按钮
        var operation_div = $('<div class="operation_div_3"></div>');
        if(change_item.indexOf(item_name) > -1){
            var submit = $('<input type="button" class="btn btn-success btn-lg btn-block" value="此子集已在审批中">');
        }else{
            // var submit = $('<input type="submit" class="btn btn-primary btn-lg btn-block" value="提交保存">');
            var submit = $('<input type="button"  class="btn btn-lg btn-primary" value="保存">');
            var add = $('<input type="button" class="btn btn-lg btn-success add_info" value="新增">');
        }
        //var callback = $('<input type="button" class="weui-btn weui-btn_disabled weui-btn_default callback_button" value="取消操作">');
        operation_div.append(submit);
        operation_div.append(add);
        //operation_div.append(callback);
        //添加表单隐藏域信息
        form.append($('<input type="hidden" name="table_name" value="'+data.name+'"/>'));
        //标记该子集是否有值 1 有 0 没有
        form.append($('<input type="hidden" name="has_value" value="0"/>'));
        form.find('div:eq(0)').append(operation_div);
        //最终生成dom节点数据
        $('body').append(form);
    }else{
        //获取有删除标记的subvalue条数
        var c = 0;
        for(var i in default_value){
            if(default_value[i].no_display){
                c++;
            }
        }
        if(c==default_value.length){
            var type = 1;
            addNew(data,type);
            return;
        }

        //统计总数
        var total = 0;
        var div1 = $('<div class="swiper-container swiper-no-swiping"></div>');
        var div2 = $('<div class="swiper-wrapper swiper-no-swiping"></div>');
        //有值状态
        for(var j=0 in default_value){
            if(!default_value[j].no_display) {
                total++;
                var temp = $('<div class="swiper-slide swiper-no-swiping"></div>');
                var form1 = createForm({action: data.action, name: data.name, method: data.method});
                //追加表格数据
                form1.append($('<div class=" weui-cells_form"></div>'));
                var json = default_value[j].info;
                var status = 1; //字段是否可编辑
                for (var i in json) {
                    //判断类型
                    var json_item = data.json;
                    var date_type = json_item[i].type;
                    var item_caption = json_item[i].caption;
                    var change_type = json[i].change_type;
                    //检测是否是为Date类型
                    if (json_item[i].type == 'DATE') {
                        var date_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputDate"></label><div class="col-sm-4"><div class=""></div></div></div>';
                        //生成date节点
                        var date_obj = $(date_html);
                        //生成左侧标题 必填加上*
                        if(kz_json[i].file){
                            var html = item_caption+'<font color="red">*</font>';
                        }else{
                            var html = item_caption;
                        }
                        date_obj.find('label').eq(0).html(html);
                        //如果有修改,标题置为red
                        if (change_type == 1) {
                            date_obj.find('label').eq(0).css('color', 'red');
                        }
                        //生成右侧日期input表单
                        var createDateValue = {
                            name: i,
                            value: json[i].value,
                            caption: json[i].caption
                        };
                        var temp_date = createTime(createDateValue,kz_json[i],status);
                        date_obj.find('div:eq(1)').append(temp_date);
                        form1.find('div:eq(0)').append(date_obj);
                    } else if (date_type == 'LIST') {
                        //生成select节点
                        // alert(date_type);
                        var select_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputList"></label><div class="col-sm-4"><div class=""></div></div></div>';
                        var select_obj = $(select_html);
                        //生成左侧标题 必填加上*
                        if(kz_json[i].file){
                            var html = item_caption+'<font color="red">*</font>';
                        }else{
                            var html = item_caption;
                        }
                        select_obj.find('label').eq(0).html(html);
                        //如果有修改,标题置为red
                        if (change_type == 1) {
                            select_obj.find('label').eq(0).css('color', 'red');
                        }
                        //分析字典 默认值
                        var select_data = {
                            name: i,
                            dictionaries: json_item[i].dictionaries,
                            default_value: json[i].value
                        };

                        var select = createSelect(select_data,kz_json[i],status);
                        select_obj.find('div:eq(1)').append(select);
                        form1.find('div:eq(0)').append(select_obj);
                    } else if (json[i].type == 'NUMBER') {
                        var number_html = '<div class=" form-group "><label class="col-sm-2  control-label" for="inputNumber"></label><div class="col-sm-4"><div class=""></div></div></div>';
                        //生成text节点
                        var number_obj = $(text_html);
                        //生成左侧标题 必填加上*
                        if(kz_json[i].file){
                            var html = item_caption+'<font color="red">*</font>';
                        }else{
                            var html = item_caption;
                        }
                        number_obj.find('label').eq(0).html(html);
                        //如果有修改,标题置为red
                        if (change_type == 1) {
                            number_obj.find('label').eq(0).css('color', 'red');
                        }
                        //生成右侧文本input表单
                        var createNumberValue = {
                            name: i,
                            value: json[i].value,
                            caption: json[i].caption
                        };
                        var temp_number = createNumber(createNumberValue,kz_json[i],status);
                        number_obj.find('div:eq(1)').append(temp_number);
                        form1.find('div:eq(0)').append(number_obj);
                    } else if (json[i].type == 'CHECKED') {
                        var checked_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputChecked"></label><div class="col-sm-4 check_radio"><div class=""></div></div></div>';
                        //生成单选节点
                        var checked_obj = $(checked_html);
                        //生成左侧标题 必填加上*
                        if(kz_json[i].file){
                            var html = item_caption+'<font color="red">*</font>';
                        }else{
                            var html = item_caption;
                        }
                        checked_obj.find('label').eq(0).html(html);
                        //如果有修改,标题置为red
                        if (change_type == 1) {
                            checked_obj.find('label').eq(0).css('color', 'red');
                        }
                        //生成右侧文本input表单
                        var createCheckedValue = {
                            name: i,
                            value: json[i].value,
                            caption: json[i].caption,
                        };
                        var temp_checked = createChecked(createCheckedValue,kz_json[i],status);
                        checked_obj.find('div:eq(1)').append(temp_checked);
                        form1.find('div:eq(0)').append(checked_obj);
                    } else {
                        var text_html = '<div class=" form-group "><label class="col-sm-2  control-label" for="inputText"></label><div class="col-sm-4"><div class=""></div></div></div>';
                        //生成text节点
                        var text_obj = $(text_html);
                        //生成左侧标题 必填加上*
                        if(kz_json[i].file){
                            var html = item_caption+'<font color="red">*</font>';
                        }else{
                            var html = item_caption;
                        }
                        text_obj.find('label').eq(0).html(html);
                        //如果有修改,标题置为red
                        if (change_type == 1) {
                            text_obj.find('label').eq(0).css('color', 'red');
                        }
                        //生成右侧文本input表单
                        var createTextValue = {
                            name: i,
                            value: json[i].value,
                            caption: json[i].caption
                        };
                        var temp_text = createText(createTextValue,kz_json[i],status);
                        text_obj.find('div:eq(1)').append(temp_text);
                        form1.find('div:eq(0)').append(text_obj);
                    }
                }

                if (change_item.indexOf(item_name) > -1) {
                    var operation_div = $('<div class="operation_div"></div>');
                    var submit = $('<input type="button" class="btn  btn-success" value="此子集已在审批中">');
                    operation_div.append(submit);
                } else {
                    //生成提交按钮 和 返回按钮
                    var operation_div = $('<div class="operation_div_2"></div>');
                    var submit = $('<input type="button"  class="btn btn-lg btn-primary" value="保存">');
                    var add = $('<input type="button" class="btn btn-lg btn-success add_info" value="新增">');
                    var del = $('<input _offset_id='+j+' type="button" class=" btn btn-lg btn-danger sub_del" value="删除">');
                    operation_div.append(submit);
                    //operation_div.append(callback);
                    operation_div.append(add);
                    operation_div.append(del);
                }
                //添加表单隐藏域信息
                form1.append($('<input type="hidden" name="table_name" value="'+data.name+'"/>'));
                form1.append($('<input type="hidden" name="has_value" value="1"/>'));
                //追加当前记录位置id
                form1.append($('<input type="hidden" name="_offset_id" value="'+j+'"/>'));
                form1.find('div:eq(0)').append(operation_div);
                //最终生成dom节点数据
                temp.append(form1);
                div2.append(temp);
            }
        }

        var page = $('<div style="position:fixed;top:-3px;z-index:0;" class="swiper-pagination"></div>');
        //判断单条数据情况 如果单条则隐藏蓝点
        if(total > 1){
            div1.append(page);
        }
        div1.append(div2);
        $('body').append(div1);
    }
}

/**
 * 非可拓展json结构 员工基本信息
 */
function formStart(data){
    var item_name = data.name; //子集名称
    var change_item = data.change_item;//已经提交审核的子集项
    var kz_json = data.kz_json;  //扩展配置数据
    dic_list = data.dic;
    pro_list = data.pro_dic;
    var form = createForm({action:data.action,name:data.name,method:data.method});
    //追加表格数据
    form.append($('<div class="weui-cells_form"></div>'));
    //获取子集数据
    var json = data.json;
    //console.log(json);return;
    //获取对象长度
    var a = 0;
    for(var i in json){
        a++;
    }
    if(a==0){
        //这里使用weui样式
        alert('没有该子集显示项!');
        history.back(-1);
        return;
    }
    var status = 1; //字段是否可编辑
    for(i in json){
        var change_type = json[i].change_type;
        //检测是否是为时间标签
        if(json[i].type=='DATE'){
            var date_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputDate"></label><div class=" col-sm-4"><div class=""></div></div></div>';
            //生成date节点
            var date_obj = $(date_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            date_obj.find('label').eq(0).html(html);
            //如果有修改,标题置为red
            if(change_type == 1){
                date_obj.find('label').eq(0).css('color','red');
            }
            //生成右侧日期input表单
            var createDateValue = {
                name:i,
                value:json[i].value,
                caption:json[i].caption,
                change_type :json[i].change_type
            };
            var temp_date = createTime(createDateValue,kz_json[i],status);
            date_obj.find('div:eq(1)').append(temp_date);
            form.find('div:eq(0)').append(date_obj);
        }else if(json[i].type=='LIST'){
            //生成select节点
            var select_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputList"></label><div class="col-sm-4"><div class=""></div></div></div>';
            var select_obj = $(select_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            select_obj.find('label').eq(0).html(html);
            //如果有修改,标题置为red
            if(change_type == 1){
                select_obj.find('label').eq(0).css('color','red');
            }
            //分析字典 默认值
            var select_data = {
                name:i,
                dictionaries:json[i].dictionaries,
                default_value:json[i].value,
                change_type:json[i].change_type
            };
            var select = createSelect(select_data,kz_json[i],status);
            select_obj.find('div:eq(1)').append(select);
            form.find('div:eq(0)').append(select_obj);
        }else if(json[i].type=='NUMBER'){
            var number_html = '<div class=" form-group "><label class="col-sm-2  control-label" for="inputNumber"></label><div class="col-sm-4"><div class=""></div></div></div>';
            //生成text节点
            var number_obj = $(number_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            number_obj.find('label').eq(0).html(html);
            //如果有修改,标题置为red
            if(change_type == 1){
                number_obj.find('label').eq(0).css('color','red');
            }
            //生成右侧文本input表单
            var createNumberValue = {
                name:i,
                value:json[i].value,
                caption:json[i].caption,
                change_type:json[i].change_type
            };
            var temp_number = createNumber(createNumberValue,kz_json[i],status);
            number_obj.find('div:eq(1)').append(temp_number);
            form.find('div:eq(0)').append(number_obj);
        }else if(json[i].type=='LIST1'){
            //生成select节点
            var select_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputList"></label><div class="col-sm-4"><div class=""></div></div></div>';
            var select_obj = $(select_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            select_obj.find('label').eq(0).html(html);
            //如果有修改,标题置为red
            if(change_type == 1){
                select_obj.find('label').eq(0).css('color','red');
            }
            //分析字典 默认值
            var select_data = {
                name:i,
                dictionaries:json[i].dictionaries,
                default_value:json[i].value,
                change_type:json[i].change_type
            };
            var select = createSelect(select_data,kz_json[i],status);
            select_obj.find('div:eq(1)').append(select);
            form.find('div:eq(0)').append(select_obj);
        }else{
            var text_html = '<div class="form-group"><label class="col-sm-2  control-label" for="inputText"></label><div class="col-sm-4"><div class=""></div></div></div>';
            //生成text节点
            var text_obj = $(text_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            text_obj.find('label').eq(0).html(html);
            //如果有修改,标题置为red
            if(change_type == 1){
                text_obj.find('label').eq(0).css('color','red');
            }
            //生成右侧文本input表单
            var createTextValue = {
                name:i,
                value:json[i].value,
                caption:json[i].caption,
                change_type :json[i].change_type
            };

            var temp_text = createText(createTextValue,kz_json[i],status);
            text_obj.find('div:eq(1)').append(temp_text);
            form.find('div:eq(0)').append(text_obj);
        }
    };
    //生成提交按钮 和 返回按钮
    var operation_div = $('<div class="operation_div3"></div>');
    if(change_item.indexOf(item_name) > -1){
        var submit = $('<input type="button" class="btn btn-success btn-lg btn-block" value="此子集已在审核中">');
    }else{
        var submit = $('<input type="submit"  class="btn btn-lg btn-primary" value="保存">');
        var add = $('<input type="button" class="btn btn-lg btn-success add_info" value="新增">');
    }

    //var callback = $('<input type="button" class="weui-btn weui-btn_disabled weui-btn_default callback_button" value="取消操作">');
    operation_div.append(submit);
    //operation_div.append(callback);
    //添加表单隐藏域信息
    form.append($('<input type="hidden" name="table_name" value="'+data.name+'"/>'));
    form.find('div:eq(0)').append(operation_div);
    //最终生成dom节点数据
    $('body').append(form);
}

/**
 * 添加新记录数据
 */
function addNew(data,type){
    dic_list = data.dic;
    var kz_json = data.kz_json;  //扩展配置数据
    console.log(kz_json);return;
    if(type == 1){
        var action = '/Pc/Info/addok';
    }else{
        var action = data.action;
    }
    var form = createForm({action:action,name:data.name,method:data.method});
    //追加表格数据
    form.append($('<div class="weui-cells_form"></div>'));
    var json = data.json;
    //获取对象长度
    var a = 0;
    for(var i in json){
        a++;
    }
    //检测是否有数据
    if(a == 0){
        alert('没有该子集显示项!');
        history.back(-1);
        return;
    }
    for(var i in json){
        //检测是否是为Date类型
        if(json[i].type=='DATE'){
            var date_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputDate"></label><div class="col-sm-4"><div class=""></div></div></div>';
            //生成date节点
            var date_obj = $(date_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            date_obj.find('label').eq(0).html(html);
            //生成右侧日期input表单
            var createDateValue = {
                name:i,
                value:json[i].value,
                caption:json[i].caption,
                change_type :json[i].change_type,
                must:json[i].must
            };

            var temp_date = createTime(createDateValue,kz_json[i]);
            date_obj.find('div:eq(1)').append(temp_date);
            form.find('div:eq(0)').append(date_obj);

        }else if(json[i].type=='LIST'){
            //生成select节点
            var select_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputList"></label><div class="col-sm-4"><div class=""></div></div></div>';
            var select_obj = $(select_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            select_obj.find('label').eq(0).html(html);
            //分析字典 默认值
            var dictionaries = json[i].dictionaries;
            var select_data = {
                name:i,
                dictionaries:dictionaries,
            };
            var select = createSelect(select_data,kz_json[i]);
            select_obj.find('div:eq(1)').append(select);
            form.find('div:eq(0)').append(select_obj);
        }else if(json[i].type=='NUMBER'){
            var number_html = '<div class=" form-group "><label class="col-sm-2  control-label" for="inputNumber"></label><div class="col-sm-4"><div class=""></div></div></div>';
            //生成text节点
            var number_obj = $(number_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            number_obj.find('label').eq(0).html(html);
            //生成右侧文本input表单
            var createNumberValue = {
                name:i,
                value:json[i].value,
                caption:json[i].caption,
                change_type:json[i].change_type,
            };
            var temp_number = createNumber(createNumberValue,kz_json[i]);
            number_obj.find('div:eq(1)').append(temp_number);
            form  .find('div:eq(0)').append(number_obj);
        }else if(json[i].type=='LIST1'){
            //生成select节点
            var select_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputList"></label><div class="col-sm-4"><div class=""></div></div></div>';
            var select_obj = $(select_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            select_obj.find('label').eq(0).html(html);
            //分析字典 默认值
            var dictionaries = json[i].dictionaries;
            var select_data = {
                name:i,
                dictionaries:dictionaries,
            };
            var select = createSelect(select_data,kz_json[i]);
            select_obj.find('div:eq(1)').append(select);
            form.find('div:eq(0)').append(select_obj);
        }else {
            var text_html = '<div class="form-group "><label class="col-sm-2  control-label" for="inputText"></label><div class="col-sm-4"><div class=""></div></div></div>';
            //生成text节点
            var text_obj = $(text_html);
            //生成左侧标题 必填加上*
            if(kz_json[i].file){
                var html = json[i].caption+'<font color="red">*</font>';
            }else{
                var html = json[i].caption;
            }
            text_obj.find('label').eq(0).html(html);
            //生成右侧文本input表单
            var createTextValue = {
                name:i,
                value:'',
                caption:json[i].caption
            };
            var temp_text = createText(createTextValue,kz_json[i]);
            text_obj.find('div:eq(1)').append(temp_text);
            form.find('div:eq(0)').append(text_obj);
        }
    }
    var operation_div = $('<div class="operation_div"></div>');
    var submit = $('<input type="button" class="btn btn-primary btn-lg btn-block" value="提交保存">');
    operation_div.append(submit);
    //添加表单隐藏域信息
    form.append($('<input type="hidden" name="table_name" value="'+data.name+'"/>'));
    form.find('div:eq(0)').append(operation_div);
    //最终生成dom节点数据
    $('body').append(form);
}

/**
 * 生成form表单对象
 */
function createForm(args){
    var dom = $("<form name='"+args.name+"' action='"+args.action+"' method='"+args.method+"'></form>");
    return dom;
}

/**
 * 生成text文本表单对象
 */
function createText(data,kz_info,status){
    var val = data.value;
    var text_input = $('<input class="form-control"  type="text" id="inputText" placeholder="请输入'+data.caption+'"/>');
    if(kz_info.file){
        text_input.attr({
            required:'required'
        });
    }
    if(status==1 && kz_info.modify){
        text_input.attr({
            disabled:'disabled'
        });
    }
    text_input.attr({
        name:data.name,
        value:val
    });

    return text_input;
}
/**
 * 生成数字表单对象
 */
function createNumber(data,kz_info,status){
    var val = data.value;
    var number_input = $('<input class="form-control"  type="number" id="inputNumber"  placeholder="请输入'+data.caption+'"/>');
    if(kz_info.file){
        number_input.attr({
            required:'required'
        });
    }
    if(status==1 && kz_info.modify){
        number_input.attr({
            disabled:'disabled'
        });
    }
    number_input.attr({
        name:data.name,
        value:val
    });
    return number_input;
}
/**
 * 生成单选按钮表单对象
 * 方法
 */
function createChecked(data,kz_info,status){
    var val = data.value;
    // console.log(data);
    var checked_input = $('<div class="radio"><label><input type="radio" value="是">是</label> 　　　<label> <input type="radio" value="否">否</label></div>');
    if(status==1 && kz_info.modify){
        checked_input.find("label>input").attr({
            disabled:'disabled'
        });
    }
    checked_input.find("label>input").attr({
        name:data.name
    });

    if(val == '是'){
        checked_input.find("label>input").eq(0).attr({
            checked:true
        });
    }else if(val == '否'){
        checked_input.find("label>input").eq(1).attr({
            checked:true
        });
    }

    return checked_input;
}
/*
 * 生成时间对象
 */
function createTime(data,kz_info,status){
    if(typeof data.value =='undefined'){
        time=data.value;
    }else{
        //截取时间长度Y-M-D
        var time=data.value.substr(0,10);
    }
    var time_input = $('<input  class="form-control" zjm="'+data.name+'" type="date" id="inputDate" />');
    time_input.attr({
        name:data.name,
        value:time
    });
    return time_input;
}

/**
 * 生成下拉select对象
 */
function createSelect(data,kz_info,status){
    var select_input = $('<select class="form-control"  id="inputList" name="select1"></select>');
    if(kz_info.file){
        select_input.attr({
            required:'required'
        });
    }
    if(status==1 && kz_info.modify){
        select_input.attr({
            disabled:'disabled'
        });
    }
    select_input.attr({
        name:data.name,
        dictionaries:data.dictionaries
    });

    //省份情况
    if(data.name=='JG' || data.name=='SF'){
        var select_input = getProvince(pro_list,data.default_value,select_input);
        return select_input;
    }else if(data.name=='CS'){
//      if(data.name=='CS'){
//          CS = data.default_value;
//      }else{
//          CSD = data.default_value;
//      }
//      var select_input = getCity(city_list,data.default_value,select_input);
        return select_input;
    }else{
        //正常情况
        var dictionaries = data.dictionaries;
        var select_input = getDictionaries(dictionaries,data.default_value,select_input);
        return select_input;
    }
}

/*
 * 获取省份下拉
 */
function getProvince(pro_list,default_value,select_obj){
    //添加请选择
    //判断默认值否是为空
    var fir_option = $('<option value="">请选择</option>');
    //排除是否选项

    //if(default_value=='' ){
    //    var empty_option = $('<option value="" selected>无</option>');
    //}else{
    //    var empty_option = $('<option value="">无</option>');
    //}
    select_obj.append(fir_option);
    //select_obj.append(empty_option);
    for(var i=0;i<pro_list.length;i++){
        var option = $('<option></option>');
        //判断是否显示
        if(pro_list[i].display==true){
            option.attr({
                value:pro_list[i].value,
            });
            //默认值选中
            if(pro_list[i].value==default_value){
                option.attr({
                    selected:true,
                });
            }
            option.html(pro_list[i].caption);
            select_obj.append(option);
        }
    }
    return select_obj;
}

/**
 * 获取市区下拉
 */
function getCity(city_list,default_value,select_obj){
    //添加请选择
    //判断默认值否是为空
    var fir_option = $('<option value="">请选择</option>');
    //排除是否选项
    //if(default_value==''){
    //    var empty_option = $('<option value="" selected>无</option>');
    //}else{
    //    //有值
    //    var empty_option = $('<option value="">无</option>');
    //}
    select_obj.append(fir_option);
    //select_obj.append(empty_option);
    return select_obj;
}

/**
 * 获取字典下拉
 */
function getDictionaries(id,default_value,select_obj){

    //判断默认值否是为空
    var fir_option = $('<option value="">请选择</option>');
    //添加无
    //检测默认值是否为空''
    //排除是否选项
    if(id!='50000001' && id!='50000002' && id!='81794617'){
        //if(default_value=='' || default_value=='无'){
        //    var empty_option = $('<option value="无" selected>无</option>');
        //}else{
        //    var empty_option = $('<option value="无">无</option>');
        //}
    }

    //添加默认项节点
    select_obj.append(fir_option);
    //console.log(dic_list[id]);return;
    var obj = dic_list[id];
    if(!obj){
        return select_obj;
    }
    var dic_subitem = obj.subitem;

    for(var j=0;j<dic_subitem.length;j++){
        var option = $('<option></option>');
        //判断是否显示
        if(dic_subitem[j].display=='true'){
            option.attr({
                value:dic_subitem[j].value
            });
            //默认值选中
            if(dic_subitem[j].value==default_value){
                option.attr({
                    selected:true
                });
            }
            option.html(dic_subitem[j].caption);
            select_obj.append(option);
        }
    }
    return select_obj;
}